.class public Lcom/qq/xgdemo/common/CommonWorkingThread;
.super Ljava/lang/Object;
.source "CommonWorkingThread.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/qq/xgdemo/common/CommonWorkingThread$CommonWorkingThreadHolder;
    }
.end annotation


# static fields
.field private static handler:Landroid/os/Handler;

.field private static thread:Landroid/os/HandlerThread;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    const/4 v0, 0x0

    .line 9
    sput-object v0, Lcom/qq/xgdemo/common/CommonWorkingThread;->thread:Landroid/os/HandlerThread;

    .line 11
    sput-object v0, Lcom/qq/xgdemo/common/CommonWorkingThread;->handler:Landroid/os/Handler;

    return-void
.end method

.method private constructor <init>()V
    .locals 0

    .prologue
    .line 13
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 14
    return-void
.end method

.method synthetic constructor <init>(Lcom/qq/xgdemo/common/CommonWorkingThread;)V
    .locals 0

    .prologue
    .line 13
    invoke-direct {p0}, Lcom/qq/xgdemo/common/CommonWorkingThread;-><init>()V

    return-void
.end method

.method public static getInstance()Lcom/qq/xgdemo/common/CommonWorkingThread;
    .locals 1

    .prologue
    .line 21
    invoke-static {}, Lcom/qq/xgdemo/common/CommonWorkingThread;->initHandler()V

    .line 22
    sget-object v0, Lcom/qq/xgdemo/common/CommonWorkingThread$CommonWorkingThreadHolder;->instance:Lcom/qq/xgdemo/common/CommonWorkingThread;

    return-object v0
.end method

.method private static initHandler()V
    .locals 4

    .prologue
    .line 48
    sget-object v0, Lcom/qq/xgdemo/common/CommonWorkingThread;->thread:Landroid/os/HandlerThread;

    if-eqz v0, :cond_0

    sget-object v0, Lcom/qq/xgdemo/common/CommonWorkingThread;->thread:Landroid/os/HandlerThread;

    invoke-virtual {v0}, Landroid/os/HandlerThread;->isAlive()Z

    move-result v0

    if-eqz v0, :cond_0

    sget-object v0, Lcom/qq/xgdemo/common/CommonWorkingThread;->thread:Landroid/os/HandlerThread;

    invoke-virtual {v0}, Landroid/os/HandlerThread;->isInterrupted()Z

    move-result v0

    if-nez v0, :cond_0

    .line 49
    sget-object v0, Lcom/qq/xgdemo/common/CommonWorkingThread;->thread:Landroid/os/HandlerThread;

    invoke-virtual {v0}, Landroid/os/HandlerThread;->getState()Ljava/lang/Thread$State;

    move-result-object v0

    sget-object v1, Ljava/lang/Thread$State;->TERMINATED:Ljava/lang/Thread$State;

    if-ne v0, v1, :cond_1

    .line 50
    :cond_0
    new-instance v0, Landroid/os/HandlerThread;

    const-string v1, "tpush.working.thread"

    invoke-direct {v0, v1}, Landroid/os/HandlerThread;-><init>(Ljava/lang/String;)V

    sput-object v0, Lcom/qq/xgdemo/common/CommonWorkingThread;->thread:Landroid/os/HandlerThread;

    .line 51
    sget-object v0, Lcom/qq/xgdemo/common/CommonWorkingThread;->thread:Landroid/os/HandlerThread;

    invoke-virtual {v0}, Landroid/os/HandlerThread;->start()V

    .line 52
    new-instance v0, Landroid/os/Handler;

    sget-object v1, Lcom/qq/xgdemo/common/CommonWorkingThread;->thread:Landroid/os/HandlerThread;

    invoke-virtual {v1}, Landroid/os/HandlerThread;->getLooper()Landroid/os/Looper;

    move-result-object v1

    invoke-direct {v0, v1}, Landroid/os/Handler;-><init>(Landroid/os/Looper;)V

    sput-object v0, Lcom/qq/xgdemo/common/CommonWorkingThread;->handler:Landroid/os/Handler;

    .line 53
    const-string v0, "CommonWorkingThread"

    new-instance v1, Ljava/lang/StringBuilder;

    const-string v2, ">>> Create new working thread."

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 54
    sget-object v2, Lcom/qq/xgdemo/common/CommonWorkingThread;->thread:Landroid/os/HandlerThread;

    invoke-virtual {v2}, Landroid/os/HandlerThread;->getId()J

    move-result-wide v2

    invoke-virtual {v1, v2, v3}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 53
    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 56
    :cond_1
    return-void
.end method


# virtual methods
.method public execute(Ljava/lang/Runnable;)Z
    .locals 2
    .param p1, "r"    # Ljava/lang/Runnable;

    .prologue
    .line 26
    sget-object v0, Lcom/qq/xgdemo/common/CommonWorkingThread;->handler:Landroid/os/Handler;

    if-eqz v0, :cond_0

    .line 27
    const-string v0, "CommonWorkingThread"

    const-string v1, ">>> working thread execute "

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 28
    sget-object v0, Lcom/qq/xgdemo/common/CommonWorkingThread;->handler:Landroid/os/Handler;

    invoke-virtual {v0, p1}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    move-result v0

    .line 30
    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public execute(Ljava/lang/Runnable;J)Z
    .locals 3
    .param p1, "r"    # Ljava/lang/Runnable;
    .param p2, "delayMillis"    # J

    .prologue
    .line 35
    sget-object v0, Lcom/qq/xgdemo/common/CommonWorkingThread;->handler:Landroid/os/Handler;

    if-eqz v0, :cond_0

    .line 36
    const-string v0, "CommonWorkingThread"

    .line 37
    new-instance v1, Ljava/lang/StringBuilder;

    const-string v2, ">>> working thread execute delayMillis "

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1, p2, p3}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 36
    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 38
    sget-object v0, Lcom/qq/xgdemo/common/CommonWorkingThread;->handler:Landroid/os/Handler;

    invoke-virtual {v0, p1, p2, p3}, Landroid/os/Handler;->postDelayed(Ljava/lang/Runnable;J)Z

    move-result v0

    .line 40
    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public getHandler()Landroid/os/Handler;
    .locals 1

    .prologue
    .line 44
    sget-object v0, Lcom/qq/xgdemo/common/CommonWorkingThread;->handler:Landroid/os/Handler;

    return-object v0
.end method
